package com.beiyou.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Author: King-lby
 * @Date Created in 2022-11-29 17:08
 */
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    @Value("${web.uploadPath}")
    private String baseUploadPath;

    //http://localhost:8083/images/a.png  ->  D:\YunJiWorkSpace\images
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        //开始 文件映射
        registry.addResourceHandler("/images/**")
                .addResourceLocations("file:"+baseUploadPath);

        //结束
        WebMvcConfigurer.super.addResourceHandlers(registry);
    }
}
